$('.labels').click(function (e) {
    $('.labels').toggleClass('xuanzhe');
})
$('#tel').blur(function (e) {
    checkTel();
});
var tell = '';
function checkTel() {
    var regex = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
    if (!regex.test($('#tel').val())) {
        $('#mobile_phone-error').text('手机号码不是一个有效号码');
        return false;
    }
    $('#mobile_phone-error').text('');
    tell = $('#tel').val();
    return tell;
}

$('#captcha').blur(function (e) {
    checkcaptcha();
});
function checkcaptcha() {
    var value = $(".caImg").attr('title');
    if ($('#captcha').val() != value) {
        $('#captcha-error').text('验证码不能为空');
        return false;
    }
    $('#captcha-error').text('');
    return true;
}
$('#telCode').blur(function (e) {
    checktelCode();
});
function checktelCode() {
    var value = $(".caImg").attr('title');
    if ($('#telCode').val() !== value) {
        $('#captcha-error').text('手机验证码不能为空');
        return false;
    }
    $('#captcha-error').text('');
    return true;
}
$('#password').blur(function (e) {
    checkpassword();
});
var pwd = '';
function checkpassword() {
    var regex = /^[a-zA-Z]\w{5,17}$/;
    if (!regex.test($('#password').val())) {
        $('#pwd-error').text('以字母开头，长度在6~18之间，只能包含字母、数字和下划线');
        return false;
    }
    $('#pwd-error').text('');
    pwd = $('#password').val();
    return pwd;
}
$('#pwdRepeat').blur(function (e) {
    checkpwdRepeat();
});
function checkpwdRepeat() {
    if ($('#pwdRepeat').val() !== $('#password').val()) {
        $('#pwdRepeat-error').text('两次输入密码不一致');
        return false;
    }
    $('#pwdRepeat-error').text('');
    return true;
}
// checkTel();
$('form').submit(function (e) {
    e.preventDefault();
    if (checkTel() && checkcaptcha() && checktelCode() && checkpassword() && checkpwdRepeat()) {
        localStorage.setItem('tel', tell);
        localStorage.setItem('password', pwd);
        location.href = 'file:///D:/%E4%BD%9C%E4%B8%9A/%E5%A4%A7%E5%95%86%E5%88%9BX/pages/register.html';
    }
    return false;
})